package com.ruoyi.cms.merit.controller;

import com.ruoyi.cms.merit.service.MeritService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/cms/merit")
public class MeritController {

    @Autowired
    private MeritService meritService;

    // 获取当前功德数
    @GetMapping("/count")
    public ResponseEntity<Map<String, Object>> getCount() {
        Long count = meritService.getMeritCount();
        return ResponseEntity.ok(Map.of("count", count));
    }

    // 功德数加一
    @PostMapping("/add")
    public ResponseEntity<Map<String, Object>> addMerit() {
        Long newCount = meritService.incrementMerit();
        return ResponseEntity.ok(Map.of("count", newCount));
    }
}
